package br.com.sisnema.aula2;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.media.MediaPlayer;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.State;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.Toast;

public class Main extends Activity {
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main); 

       
       
       ConnectivityManager conn = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
       
       ImageView imgWifi = (ImageView)findViewById(R.id.imgWifi);
       ImageView imgNotConnection = (ImageView)findViewById(R.id.imgNotConnection);
       ImageView imgTresG = (ImageView)findViewById(R.id.imgTresG);
       
       
       if(conn.getNetworkInfo(0).getState() == State.CONNECTED){
    	   imgWifi.setVisibility(8);
    	   imgNotConnection.setVisibility(8);
    	   imgTresG.setVisibility(0);
       } else if(conn.getNetworkInfo(1).getState() == State.CONNECTED){
    	   imgWifi.setVisibility(0);
    	   imgNotConnection.setVisibility(8);
    	   imgTresG.setVisibility(8);
       } else {
    	   imgWifi.setVisibility(8);
    	   imgNotConnection.setVisibility(0);
    	   imgTresG.setVisibility(8);
       }
       
       
       TelephonyManager th = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
       Toast.makeText(getBaseContext(), th.getDeviceId(), Toast.LENGTH_LONG).show();
    }

    
    @Override
    public void onResume(){
    	super.onResume();
    	Log.i("Main", "OnResume - AQUI");
    }
    
    @Override
    public void onPause(){
    	super.onPause();
    	Log.i("Main", "OnPause - AQUI");
    }
    
    @Override
    public void onDestroy(){
    	super.onDestroy();
    	Log.i("Main", "OnDestroy - AQUI");
    }
    
    public void Cadastro_Click(View v){
    	startActivityForResult(new Intent(getBaseContext(), Cadastro.class), 0);
    }
    
    public void Replicar_Click(View v){
    	startService(new Intent("INICIAR_SERVICO"));
    }
    
    public void Editar_Click(View v){
    	startActivity(new Intent(getBaseContext(), Editar.class));
    }

    public void Listar_Click(View v){
    	startActivity(new Intent(getBaseContext(), ListarNovo.class));
    }
}